<template>
  <v-snackbar v-model="show" bottom right :timeout="timeout">
    {{ message }}
    <v-btn flat color="pink" @click.native="show = false">
      Close
    </v-btn>
  </v-snackbar>
</template>

<script>
export default {
  data () {
    return {
      show: false,
      message: '',
      timeout: ''
    }
  },
  created: function () {
    this.$store.watch(state => state.snackbar.message, () => {
      console.log(this.$store.state.snackbar)
      const msg = this.$store.state.snackbar.message
      const timeout = this.$store.state.snackbar.timeout
      if (msg !== '') {
        this.show = true
        this.message = msg
        this.timeout = timeout
        // this.$store.commit('snackbar/setSnack', '')
      }
    })
  }
}
</script>
